﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SimpleDatabaseAdapter
{
    internal class DataTableUtils
    {
        internal static string GetFieldValue(object cell)
        {
            if (cell != null)
            {
                return cell.ToString();
            }
            else
            {
                return String.Empty;
            }
        }

        internal static bool TryGetFieldValueInt(object cell, out int dataInt)
        {
            string strData = GetFieldValue(cell);
            bool isParse = int.TryParse(strData, out dataInt);
            return isParse;
        }

        internal static bool TryGetFieldValueLong(object cell, out long dataLong)
        {
            string strData = GetFieldValue(cell);
            bool isParse = long.TryParse(strData, out dataLong);
            return isParse;
        }

        internal static bool TryGetFieldValueDateTime(object cell, out DateTime dataDateTime)
        {
            string strData = GetFieldValue(cell);
            bool isParse = DateTime.TryParse(strData, out dataDateTime);
            return isParse;
        }
    }
}
